
#include "gameelements.h"

void MyMessage::SetData(DataIN UINT nMsgID,DataIN void* pData,DataIN UINT nDataSize,DataOUT GameMSG* pMsg)
{
	pMsg->ID = nMsgID;
	if (pData == NULL)
	{
		return;
	}
	if (nDataSize >= pMsg->MaxBufLength)
	{
		return;
	}
	memcpy(pMsg->buf,pData,nDataSize);
	pMsg->buf[nDataSize] = 0;
	pMsg->DataSize = nDataSize;
	return;
}

UINT MyMessage::GetData(DataIN GameMSG* pMsg,DataOUT void* pData)
{
	if (pMsg == NULL)
	{
		return (UINT)(-1);
	}
	if (pMsg->DataSize <= 0)
	{
		return (UINT)(-1);
	}
	UINT id = pMsg->ID;
	memcpy(pData,pMsg->buf,pMsg->DataSize);
	return id;
}

